-
Notifications
You must be signed in to change notification settings - Fork 6
[Neo4j] Switch to the new subquery import syntax (again) #3386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request updates how subqueries are constructed across various repository and core query modules. Changes include replacing anonymous functions with an array of string or variable identifiers in subQuery calls, eliminating redundant Changes
Possibly related PRs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/core/database/query/match-project-based-props.ts (1)
108-108
: Consider using array syntax for consistency.While passing a single string variable works, consider using an array syntax
[projectVar]
to maintain consistency with other subQuery calls in the codebase which use arrays for imports.- query.comment`matchProjectSens()`.subQuery(projectVar, (sub) => + query.comment`matchProjectSens()`.subQuery([projectVar], (sub) =>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (23)
src/components/budget/budget-record.repository.ts
(2 hunks)src/components/budget/budget.repository.ts
(1 hunks)src/components/comments/comment-thread.repository.ts
(1 hunks)src/components/engagement/engagement.repository.ts
(1 hunks)src/components/engagement/handlers/apply-finalized-changeset-to-engagement.handler.ts
(3 hunks)src/components/file/file.repository.ts
(1 hunks)src/components/language/language.repository.ts
(2 hunks)src/components/notifications/notification.repository.ts
(1 hunks)src/components/organization/organization.repository.ts
(1 hunks)src/components/partner/partner.repository.ts
(2 hunks)src/components/partnership/handlers/apply-finalized-changeset-to-partnership.handler.ts
(2 hunks)src/components/partnership/partnership.repository.ts
(2 hunks)src/components/periodic-report/periodic-report.repository.ts
(1 hunks)src/components/progress-report/progress-report-extra-for-periodic-interface.repository.ts
(3 hunks)src/components/progress-report/variance-explanation/variance-explanation.repository.ts
(1 hunks)src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts
(1 hunks)src/components/project/project.repository.ts
(1 hunks)src/components/user/user.repository.ts
(2 hunks)src/core/database/query-augmentation/subquery.ts
(2 hunks)src/core/database/query/filters.ts
(1 hunks)src/core/database/query/match-project-based-props.ts
(3 hunks)src/core/database/query/properties/update-property.ts
(1 hunks)src/core/database/query/sorting.ts
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (5)
src/components/partner/partner.repository.ts (1)
src/core/database/query/filters.ts (1)
sub
(229-261)
src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts (1)
src/core/database/query/filters.ts (1)
sub
(229-261)
src/components/budget/budget.repository.ts (1)
src/core/database/query/filters.ts (1)
sub
(229-261)
src/core/database/query-augmentation/subquery.ts (2)
src/core/database/query/filters.ts (1)
sub
(229-261)src/core/database/query-augmentation/SubClauseCollection.ts (1)
SubClauseCollection
(4-43)
src/components/comments/comment-thread.repository.ts (1)
src/core/database/query/matching.ts (1)
ACTIVE
(27-27)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: E2E Tests (neo4j 6/6)
- GitHub Check: E2E Tests (neo4j 5/6)
- GitHub Check: E2E Tests (neo4j 4/6)
- GitHub Check: E2E Tests (neo4j 3/6)
- GitHub Check: E2E Tests (neo4j 2/6)
- GitHub Check: Generate (head)
- GitHub Check: E2E Tests (neo4j 1/6)
- GitHub Check: Generate (base)
- GitHub Check: lint
- GitHub Check: Unit
- GitHub Check: Clean
🔇 Additional comments (41)
src/components/progress-report/variance-explanation/variance-explanation.repository.ts (1)
44-51
: Clean simplification of the subquery import syntax.The change to directly pass
['report', 'node']
array to thesubQuery
method simplifies the code by removing the need for a separate context variable and the.with()
clause. This is consistent with the new subquery import syntax being implemented across the codebase.src/components/partnership/handlers/apply-finalized-changeset-to-partnership.handler.ts (2)
36-49
: LGTM: Updated to the new subquery import syntax.The change to directly pass
['project', 'changeset']
array to thesubQuery
method simplifies the code by eliminating the need for an explicit.with()
clause while maintaining the same variables in the subquery context.
60-73
: LGTM: Consistently implementing the new subquery import pattern.This change mirrors the earlier modification in the same file, ensuring consistency in how subqueries are defined throughout the handler.
src/components/organization/organization.repository.ts (1)
94-106
: LGTM: Successfully updated to the new subquery import syntax.The change to directly pass
'projList'
to thesubQuery
method eliminates the need for an explicit.with()
clause while maintaining the same functionality. This simplifies the query structure and makes the code more readable.src/components/notifications/notification.repository.ts (1)
151-168
: LGTM: Updated to new subquery import pattern.The change to directly pass
'node'
to thesubQuery
method follows the new subquery import syntax being implemented across the codebase. The complex internal hydration logic remains intact while the query structure is simplified.src/components/periodic-report/periodic-report.repository.ts (1)
383-392
: Improved subquery structure with explicit variable importThe changes in the subQuery call make the code more explicit about which variables are being imported into the subquery. This approach is cleaner than the previous method of using an anonymous function and a
.with('node')
clause within it.src/components/budget/budget.repository.ts (1)
191-196
: Streamlined subquery with explicit variable importsThe change replaces the anonymous function that included a
.with('project, budget')
call with an explicit array of variables['project', 'budget']
passed directly to thesubQuery
method. This eliminates the redundant.with()
call and makes the code cleaner and more maintainable.src/core/database/query/properties/update-property.ts (1)
200-210
: Improved subquery structure and reduced redundancyThis change makes two important improvements:
- It now explicitly passes the
imports
array to thesubQuery
method, clearly showing which variables are being imported- It removes a redundant
.with(imports)
call, making the query more efficientThis aligns well with the new subquery syntax being implemented across the codebase.
src/components/file/file.repository.ts (1)
138-151
: Standardized subquery import syntaxThe change replaces the anonymous function approach with an explicit string identifier for the variable being imported into the subquery. This follows the new pattern being implemented throughout the codebase for more consistent and readable query structures.
src/components/engagement/handlers/apply-finalized-changeset-to-engagement.handler.ts (3)
39-39
: Improved subquery clarity with explicit variable importsThe change from an anonymous function to an array of explicit variable imports
['project', 'changeset']
makes the variable dependencies clearer upfront and eliminates the need for an explicit.with()
clause. This aligns with the PR's goal of using the new subquery import syntax.
65-65
: Consistent application of new subquery syntaxGood continuation of applying the new subquery import syntax pattern throughout the handler. The explicit array of imports
['project', 'changeset']
makes the query more readable by clearly declaring which variables are being used in the subquery context.
96-96
: Completed consistent implementation of new subquery syntaxThe third instance of subquery modification maintains consistency with the previous changes. This pattern improves query readability and maintenance by making variable dependencies explicit at the start of the subquery.
src/components/project/project.repository.ts (4)
367-368
: Updated node reference from 'project' to 'outer'Changed variable reference in
getPath
helper for the sorter to use 'outer' instead of 'project'. This matches the new standardized approach for sorters to reference the outer variable consistently.
375-375
: Simplified variable reference in union clauseReplaced
.with('node as project')
with.with('outer')
, simplifying the query and maintaining consistency with the variable naming used in the path definition.
382-383
: Consistent variable naming in primaryPartnership sorterThe 'primaryPartnership' sorter now also uses 'outer' as its variable reference, ensuring consistency with the previous 'primaryLocation' sorter. This standardization makes the code more maintainable.
392-392
: Completed standardization of sorter variable referencesFinal instance of changing variable reference to 'outer' in the union clause of the 'primaryPartnership' sorter, completing the consistent application of the new variable naming approach.
src/components/user/user.repository.ts (2)
280-281
: Explicitly defined subquery variable importsUpdated subQuery to use the new syntax with explicit array of variables
['user', 'org']
instead of the previous anonymous function approach. This makes it clear which variables are being imported into the subquery scope.
294-294
: Maintained consistency in nested subquery implementationApplied the same subquery syntax update within the conditional code block, ensuring that both subqueries in this method use the new explicit imports pattern. Consistency across the codebase makes maintenance easier.
src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts (1)
39-39
: Adopted new subquery import syntax for budget record handlingUpdated the subquery implementation to use explicit variable imports
['node', 'changeset']
, which aligns with the changes made throughout the codebase. This clarifies which variables from the outer query are accessible within the subquery.This change is part of the broader effort to standardize subquery syntax across the codebase as mentioned in the PR description. The explicit import approach prevents potential issues with variable scoping and makes the query dependencies clearer.
src/core/database/query/sorting.ts (1)
143-149
: Improved subquery structure in the matcher functionThe refactored matcher implementation creates a cleaner separation between outer and inner query contexts by explicitly defining the 'outer' node and using it in the subquery. This change follows the new subquery import syntax pattern being applied across the codebase, improving readability and consistency.
src/components/engagement/engagement.repository.ts (3)
901-908
: Standardized variable naming in language sub-queryRenamed
node
reference toouter
to follow the new subquery pattern, improving consistency with other parts of the codebase. This change simplifies the query structure by eliminating redundant variable renaming.
911-913
: Standardized variable naming in project sub-queryRenamed the node reference to
outer
to maintain consistency with the new subquery pattern being implemented throughout the codebase.
916-934
: Improved subquery structure in progress report sortingChanged to use the more standardized pattern by explicitly defining
outer as parent
and then using it directly in the subQuery call. This approach creates a cleaner separation between query contexts and improves readability.src/components/partner/partner.repository.ts (2)
212-224
: Improved subQuery implementation in hydrate methodChanged to directly pass 'projList' as a parameter to subQuery instead of using an intermediate
.with()
clause. This simplifies the query structure and aligns with the new subquery import syntax pattern being applied across the codebase.
354-358
: Standardized node variable name for consistencyRenamed the node reference from 'partner' to 'outer' to maintain consistency with the standardized variable naming convention used across all sorters. This alignment with the pattern used in
filter.sub()
(which defaults to 'outer') makes the code more maintainable and easier to understand.src/components/language/language.repository.ts (2)
189-201
: Enhanced subQuery implementation with explicit variable passingChanged to pass an array of variables ['projList', 'props'] to subQuery, making it explicit which variables are needed in the subquery context. This follows the new subquery import syntax pattern, improving clarity and maintainability.
384-388
: Standardized node variable name for consistencyRenamed the node reference from 'lang' to 'outer' to maintain consistency with the standardized variable naming convention used across all repositories. This change aligns with the pattern used in
filter.sub()
which defaults to 'outer' as the variable name.src/components/progress-report/progress-report-extra-for-periodic-interface.repository.ts (3)
57-58
: Standardized variable naming withouter
Good change! Renaming from
node('report')
tonode('outer')
aligns with the standardized naming convention used throughout the codebase for the outer node in sorter definitions.
68-69
: Standardized variable naming withouter
Good change! Renaming from
node('report')
tonode('outer')
in the engagement sorter is consistent with the change in the pnpExtractionResult sorter above, and maintains consistency throughout sorter implementations.
82-102
: Improved subQuery implementation for periodSummary matcherGreat restructuring of the periodSummary matcher! The new implementation:
- Uses the
subQuery
method with an explicit variable name 'report'- Encapsulates the matching logic within a clean subquery context
- Maintains the same functionality while improving code clarity
This change is consistent with the PR objectives of standardizing query construction.
src/components/comments/comment-thread.repository.ts (1)
56-71
: Improved subQuery structure for comment thread hydrationNice restructuring of the nested subquery logic! The changes:
- Replace the previous implementation with a cleaner nested
subQuery('thread', (sub2) =>
approach- Make the variable scoping more explicit
- Improve the readability of the nested query structure
- Return 'comments' directly at the end of the subquery chain
This implementation is more maintainable and aligns with the standardized subquery pattern used throughout the codebase.
src/components/partnership/partnership.repository.ts (2)
283-313
: Improved subQuery implementation with explicit variable passingGood change! Replacing
subQuery((sub) =>
withsubQuery(['project', 'partner'], (sub) =>
makes it explicit which variables are being carried forward into the subquery, eliminating the need for separate.with
clauses.This implementation is more straightforward and aligns with the PR's goal of standardizing subquery syntax.
443-443
: Standardized variable naming withouter
Good change! Renaming from
node('partnership')
tonode('outer')
in the partnershipSorters aligns with the standardized naming convention for the outer node in sorter definitions throughout the codebase.src/components/budget/budget-record.repository.ts (2)
158-158
: Improved subQuery implementation with explicit variable passingGood change! Replacing
subQuery((sub) =>
withsubQuery([recordVar, projectVar], (sub) =>
makes it explicit which variables are being carried forward into the subquery. This eliminates ambiguity and improves the clarity of the query structure.
201-201
: Improved subQuery implementation with explicit variable passingGood change! Replacing
subQuery((sub) =>
withsubQuery(budgetVar, (sub) =>
makes it explicit which variable is being carried forward into the subquery. This is consistent with the pattern used throughout the PR.src/core/database/query/filters.ts (1)
245-259
: Implementation of the new subquery structure looks good.The code changes here replace the previous single-level subquery with a nested structure that explicitly imports variables. The implementation properly:
- Creates an outer subquery that imports
['node', ...input]
- Creates an inner subquery that imports
[...outerVar, ...input]
- Maintains the original functionality while making variable imports explicit
This aligns well with the new subquery syntax being adopted throughout the codebase.
src/core/database/query-augmentation/subquery.ts (3)
9-17
: Clear, updated documentation for subQuery method.The documentation has been properly updated to reflect the new CALL syntax with explicitly imported variables. The example is more practical and demonstrates the preferred usage pattern.
43-57
: Cleaner implementation of the subQuery method.The refactored code is more straightforward:
- Simplifies variable handling based on whether
subOrImport
is a function- Directly builds the imports array from the provided variables
- Creates a more explicit flow for building and executing the subquery
This implementation makes the code easier to understand and maintain.
62-72
: Improved SubQueryClause implementation.The updated SubQueryClause now:
- Takes a
scope
parameter consisting of variables to be imported- Properly formats the CALL clause with these imported variables
- Maintains the existing SubClauseCollection functionality
This change provides better support for the explicit variable import pattern.
src/core/database/query/match-project-based-props.ts (2)
25-50
: Good application of the new subQuery syntax.The updated implementation correctly uses the new array-based syntax for importing variables, making it clear which variables are being passed into the subquery context. The code maintains its original functionality while adopting the new pattern.
155-173
: Good implementation of the new subQuery pattern.The function has been properly updated to use the explicit variable import pattern. The code is well-formatted and maintains the original functionality while adopting the new syntax.
Trying #3382 again.
Accounting for import aliases this time, and avoiding match patterns that need to declare a new variable that is also an import name.